home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Util / conv / Acvt.lha / Acvt 1.07 / sources / switches.cpp < prev    next >
C/C++ Source or Header  |  1999-06-17  |  3KB  |  156 lines

  1. //THIS IS A GENERATED FILE. DO NOT EDIT!!!
  2. //EDIT switches.def INSTEAD!
  3.  
  4.  
  5. int m_iArgsCurr;
  6. int m_iArgsOrig;
  7. char** m_ppcArgvOrig;
  8. char** m_ppcArgvCurr;
  9. char* m_szSwitch;
  10.  
  11. //gets one token from cmdline
  12. BOOL SWITCHES_GetSwitch()
  13. {
  14.     if ( !m_iArgsCurr )
  15.         return FALSE;
  16.     
  17.     m_szSwitch = *( m_ppcArgvCurr++ );
  18.     
  19.     m_iArgsCurr--;
  20.     
  21.     return TRUE;
  22. }
  23.  
  24. //gets one token, returns TRUE if value
  25. BOOL SWITCHES_GetValue()
  26. {
  27.     if ( !SWITCHES_GetSwitch() )
  28.         return FALSE;
  29.     
  30.     switch( *m_szSwitch )
  31.     {
  32.         case '-':
  33.         case '/':
  34.             return FALSE;
  35.         default:
  36.             return TRUE;
  37.     }
  38. }
  39.  
  40.  
  41. BOOL SWFN_HELP( char* szUsage )
  42. {
  43.     if ( szUsage )
  44.         printf( "%s\n", szUsage );
  45.     printf( "-help         -this help\n" );
  46.     printf( "-v            -verbose output\n" );
  47.     printf( "-atr          -output is ATR\n" );
  48.     printf( "-xfd          -output is XFD\n" );
  49.     printf( "-scp          -output is SCP\n" );
  50.     printf( "-dcm          -output is DCM\n" );
  51.     printf( "-batch        -batch mode\n" );
  52.     printf( "-errstop      -in batchmode stop on first error\n" );
  53.     printf( "-over         -turns on file overwriting\n" );
  54.     printf( "-autorepair   -auto repair mode\n" );
  55.     printf( "-norepair     -don't repair\n" );
  56.     printf( "-test         -only test input files\n" );
  57.     return FALSE;
  58. }
  59.  
  60.  
  61. BOOL SWITCHES_Init( int* pargc, char** argv )
  62. {
  63.     BOOL bRet = TRUE;
  64.     
  65.     m_iArgsCurr = *pargc - 1;
  66.     m_iArgsOrig = 1;
  67.     m_ppcArgvOrig = argv + 1;
  68.     m_ppcArgvCurr = argv + 1;
  69.     
  70.     while( m_iArgsCurr )
  71.     {
  72.         if ( !bRet )
  73.             break;
  74.         
  75.         if ( SWITCHES_GetValue() )
  76.         {
  77.             bRet = TRUE;
  78.             *( m_ppcArgvOrig++ ) = * ( m_ppcArgvCurr - 1 );
  79.             m_iArgsOrig++;
  80.         }
  81.         else
  82.         {
  83.             m_szSwitch++;
  84.             
  85.             bRet = TRUE;
  86.             
  87.             if (!strcmp( m_szSwitch, "help" ) || !strcmp( m_szSwitch, "?" ))
  88.             {
  89.                 bRet = SWFN_HELP( USAGE );
  90.                 continue;
  91.             }
  92.             if (!strcmp( m_szSwitch, "v" ))
  93.             {
  94.                 g_bVerbose = TRUE;
  95.                 continue;
  96.             }
  97.             if (!strcmp( m_szSwitch, "atr" ) || !strcmp( m_szSwitch, "a" ))
  98.             {
  99.                 g_dtypeOut = DISK_ATR;
  100.                 continue;
  101.             }
  102.             if (!strcmp( m_szSwitch, "xfd" ) || !strcmp( m_szSwitch, "x" ))
  103.             {
  104.                 g_dtypeOut = DISK_XFD;
  105.                 continue;
  106.             }
  107.             if (!strcmp( m_szSwitch, "scp" ) || !strcmp( m_szSwitch, "s" ))
  108.             {
  109.                 g_dtypeOut = DISK_SCP;
  110.                 continue;
  111.             }
  112.             if (!strcmp( m_szSwitch, "dcm" ) || !strcmp( m_szSwitch, "d" ))
  113.             {
  114.                 g_dtypeOut = DISK_DCM;
  115.                 continue;
  116.             }
  117.             if (!strcmp( m_szSwitch, "batch" ) || !strcmp( m_szSwitch, "batchmode" ) || !strcmp( m_szSwitch, "b" ))
  118.             {
  119.                 g_bBatchMode = TRUE;
  120.                 continue;
  121.             }
  122.             if (!strcmp( m_szSwitch, "errstop" ))
  123.             {
  124.                 g_bFirstErrStop = TRUE;
  125.                 continue;
  126.             }
  127.             if (!strcmp( m_szSwitch, "over" ) || !strcmp( m_szSwitch, "overwrite" ))
  128.             {
  129.                 g_bOverWrite = TRUE;
  130.                 continue;
  131.             }
  132.             if (!strcmp( m_szSwitch, "autorepair" ))
  133.             {
  134.                 g_bRepairAuto = TRUE;
  135.                 continue;
  136.             }
  137.             if (!strcmp( m_szSwitch, "norepair" ))
  138.             {
  139.                 g_bRepair = FALSE;
  140.                 continue;
  141.             }
  142.             if (!strcmp( m_szSwitch, "test" ))
  143.             {
  144.                 g_bTestOnly = TRUE;
  145.                 continue;
  146.             }
  147.             
  148.             printf( "Invalid switch: %s\n", *( m_ppcArgvCurr - 1 ) );
  149.             return FALSE;
  150.         } //endif
  151.     } //while
  152.     
  153.     *pargc = m_iArgsOrig;
  154.     return bRet;
  155. }
  156.